package scuts.core.instances;
import scuts.core.classes.Enumeration;



class EnumerationDateInDays extends Enumeration<Date>{
  
  // boilerplate, should be avoided
  public static var get(getInstance, null):EnumerationDateInDays;
  
  static function getInstance ()
  {
    if (get == null) get = new EnumerationDateInDays();
    return get;
  }
  function new () {}
  
  override public function fromEnum (d:Date):Int {
    return Math.floor(d.getTime()/(1000.0*60.0*60.0*24.0)+(1.0/24.0));
  }
  
  override public function toEnum (i:Int):Date {
    return Date.fromTime(i*(1000.0*60.0*60.0*24.0) - (1000.0*60.0*60.0*1.0));
  }
}